﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CNVP.JShop.UI;
using CNVP.Framework;
using CNVP.Config;
using CNVP.Framework.Utils;

namespace CNVP.JShop.Web.Admin
{
    public partial class ReviewReply :AdminPage
    {
        BLL.CNVP_Review bll = new BLL.CNVP_Review();
        Model.CNVP_Review model = new Model.CNVP_Review();
        public int id = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!BLL.BLLCheckAdmin.LoginOk(Page, 129) || !BLL.BLLCheckAdmin.LoginOk(Page, 130)) return;//判断页面权限
            if (!string.IsNullOrEmpty(Request.QueryString["ID"]) && Public.IsNumber(Request.QueryString["ID"]))
            {
                id = Convert.ToInt32(Request.QueryString["ID"]);
            }
            if (!IsPostBack)
            {
                if (id > 0)
                {
                    lbTitle.Text = " > 回复";
                    DataInfo(id);
                }
            }
        }

        public void DataInfo(int id)
        {
            model = bll.GetSingle_CNVP_ReviewById(id);
            if (model != null)
            {
                lbtxtUserID.Text = model.UserID;
                lbReviewTitle.Text = model.ReviewTitle;
                lbReviewContent.Text = model.ReviewContent;
                txtLastReplyContent.Text = model.LastReplyContent;
            }
        }

        protected void btUp_Click(object sender, EventArgs e)
        {

            if (id > 0)
            {
                int rows = new BLL.CNVP_Review().Reply_CNVP_Review(new Model.CNVP_Review()
                {
                    ID = id,
                    LastReplyAuthor = CookieString,
                    LastReplyTime= DateTime.Now,
                    LastReplyContent= txtLastReplyContent.Text
                });
                if (rows == 1)
                {
                    BasePage.MessageBox("回复成功！", Request.QueryString["GoToPage"]+".aspx?Page=" + Request.QueryString["Page"] + "");
                }
                else
                {
                    MessageUtils.ShowPre("回复失败！");
                }
            }
        }
    }
}